<template>
  <div>
    <el-form :model="ruleForm" status-icon class="demo-ruleForm">
      <span>欢迎来到凯尔集团</span>
      <el-form-item label="账号:" prop="name" label-width="80px">
        <el-input v-model.number="ruleForm.name"></el-input>
      </el-form-item>

      <el-form-item label="密码:" prop="pass" label-width="80px">
        <el-input type="password" v-model="ruleForm.pass" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="btn">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'LogIn',
  data() {
    return {
      ruleForm: {
        name: 'admin',
        pass: '123456'
      }
    }
  },
  methods: {
    btn() {
      if (this.ruleForm.name === 'admin' && this.ruleForm.pass === '123456') {
        localStorage.setItem('token', 'BMuHLiHIqjzFuydiKj7LbKaGe6rpQXS0iupHAdke3vy43jKtIvAcRgGg3RyTekyL')
        console.log(this.$store)
        this.$store.commit('Uptoken', 'BMuHLiHIqjzFuydiKj7LbKaGe6rpQXS0iupHAdke3vy43jKtIvAcRgGg3RyTekyL')
        this.$router.push('/')
        console.log(this.$router)
      } else {
        this.$message.error('账号密码错误')
      }
    }
  }
}
</script>

<style>
.el-form {
  width: 500px;
  height: 500px;
  border: 1px solid pink;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
}
.el-form-item {
  margin: 0 auto;
  width: 400px;
  padding: 30px 0;
}
span {
  font-weight: 900;
  font-size: 25px;
}
</style>
